import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from "../views/Login";
import UserInfo from "../views/management/UserInfo";
import Invitation from "../views/management/Invitation";
import AccountManagement from "../views/management/AccountManagement";
import Favorites from "../views/management/Favorites";
import FollowsFans from "../views/management/FollowsFans";
import Index from "../views/Index";
import Upload from "@/views/Upload";
import Post from '@/views/Post';
import Communication from "@/views/Communication";
import CommunicationDetail from "@/views/CommunicationDetail";
import UploadRecords from "@/views/management/UploadRecords";
import ImproveInfo from "@/views/ImproveInfo";
import UserDetail from "@/views/UserDetail";
import ChangePwd from "@/views/management/ChangePwd";
import ChangeAvatar from "@/views/management/ChangeAvatar";
import AdminIndex from "@/views/Admin/AdminIndex";
import AdminCoursewares from "@/views/Admin/AdminCoursewares";
import AdminInvitation from "@/views/Admin/AdminInvitation";
import AdminResourses from "@/views/Admin/AdminResourses";
import AdminSoftwares from "@/views/Admin/AdminSoftwares";

// import Video from "../views/IndexTab/OnDemand/Video"

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/login',
    name: 'Login',
    component: Login,
    meta:{
      isLogin: true
    }
  },
  {
    path: '/improve-info',
    name: 'improveInfo',
    component: ImproveInfo,
    meta:{
      isLogin: true
    }
  },
  {
    path: '/index',
    name: 'Index',
    component: Index,
    meta:{
      showNav: false,
      title: 'index'
    }
  },
  {
    path: '/upload',
    name: 'Upload',
    component: Upload,
    meta:{
      showNav: false,
      title: 'upload'
    }
  },
  {
    path: '/post',
    name: 'Post',
    component: Post,
    meta:{
      showNav: false,
      title: 'post'
    }
  },
  {
    path: '/communication',
    name: 'Communication',
    component: Communication,
    meta:{
      showNav: false,
      title: 'communication'
    }
  },
  {
    path: '/communication-detail',
    name: 'communicationDetail',
    component: CommunicationDetail,
    meta:{
      showNav: false,
      title: 'communication-detail'
    }
  },
  {
    path: '/user-detail',
    name: 'userDetail',
    component: UserDetail,
    meta:{
      showNav: false,
      title: 'user-detail'
    }
  },
  {
    path: '/info',
    name: 'UserInfo',
    component: UserInfo,
    meta:{
      showNav: true,
      title: 'info'
    }
  },
  {
    path: '/invitation',
    name: 'Invitation',
    component: Invitation,
    meta:{
      showNav: true,
      title: 'info'
    }
  },
  {
    path: '/upload-records',
    name: 'UploadRecords',
    component: UploadRecords,
    meta:{
      showNav: true,
      title: 'info'
    }
  },
  {
    path: '/accountManagement',
    name: 'accountManagement',
    component: AccountManagement,
    meta:{
      showNav: true,
      title: 'info'
    }
  },
  {
    path: '/favorites',
    name: 'favorites',
    component: Favorites,
    meta:{
      showNav: true,
      title: 'info'
    }
  },
  {
    path: '/followsFans',
    name: 'followsFans',
    component: FollowsFans,
    meta:{
      showNav: true,
      title: 'info'
    }
  },
  {
    path: '/change-password',
    name: 'changePassword',
    component: ChangePwd,
  },
  {
    path: '/change-avatar',
    name: 'ChangeAvatar',
    component: ChangeAvatar,
  },
  {
    path: '/admin-index',
    name: 'adminIndex',
    component: AdminIndex,
    meta:{
      showNav: true,
      role: 'admin'
    }
  },
  {
    path: '/admin-coursewares',
    name: 'adminCoursewares',
    component: AdminCoursewares,
    meta:{
      showNav: true,
      role: 'admin'
    }
  },
  {
    path: '/admin-invitation',
    name: 'AdminInvitation',
    component: AdminInvitation,
    meta:{
      showNav: true,
      role: 'admin'
    }
  },
  {
    path: '/admin-resourses',
    name: 'AdminResourses',
    component: AdminResourses,
    meta:{
      showNav: true,
      role: 'admin'
    }
  },
  {
    path: '/admin-softwares',
    name: 'AdminSoftwares',
    component: AdminSoftwares,
    meta:{
      showNav: true,
      role: 'admin'
    }
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

//设置路由导航拦截：
// router.beforeEach((to,from,next)=>{
//   if(!window.localStorage.getItem('token') && !window.localStorage.getItem('username') && to.meta.isToken == true){
//     router.push('/login')
//     this.$message.error('请重新登录')
//     return
//   }
//   next()
// })

export default router
